Skip to content

Commit

Permalink
Merge branch 'COOK-1782'
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed Oct 20, 2012
2 parents 9fbc8c0 + a10ba94 commit a882414
Show file tree
Hide file tree
Showing 15 changed files with 375 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.bundle
.cache
.kitchen
bin
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source :rubygems

gem 'test-kitchen'
115 changes: 115 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
GEM
remote: http://rubygems.org/
specs:
archive-tar-minitar (0.5.2)
bunny (0.7.9)
chef (10.14.4)
bunny (>= 0.6.0, < 0.8.0)
erubis
highline (>= 1.6.9)
json (>= 1.4.4, <= 1.6.1)
mixlib-authentication (>= 1.3.0)
mixlib-cli (>= 1.1.0)
mixlib-config (>= 1.1.2)
mixlib-log (>= 1.3.0)
mixlib-shellout
moneta
net-ssh (~> 2.2.2)
net-ssh-multi (~> 1.1.0)
ohai (>= 0.6.0)
rest-client (>= 1.0.4, < 1.7.0)
treetop (~> 1.4.9)
uuidtools
yajl-ruby (~> 1.1)
childprocess (0.3.6)
ffi (~> 1.0, >= 1.0.6)
coderay (1.0.8)
erubis (2.7.0)
ffi (1.1.5)
foodcritic (1.6.1)
erubis
gherkin (~> 2.11.1)
gist (~> 3.1.0)
nokogiri (= 1.5.0)
pry (~> 0.9.8.4)
rak (~> 1.4)
treetop (~> 1.4.10)
yajl-ruby (~> 1.1.0)
gherkin (2.11.5)
json (>= 1.4.6)
gist (3.1.0)
hashr (0.0.22)
highline (1.6.15)
i18n (0.6.1)
ipaddress (0.8.0)
json (1.5.4)
librarian (0.0.25)
archive-tar-minitar (>= 0.5.2)
chef (>= 0.10)
highline
thor (~> 0.15)
log4r (1.1.10)
method_source (0.7.1)
mime-types (1.19)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.2.2)
mixlib-config (1.1.2)
mixlib-log (1.4.1)
mixlib-shellout (1.1.0)
moneta (0.6.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.2.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
net-ssh-multi (1.1)
net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0)
nokogiri (1.5.0)
ohai (6.14.1)
ipaddress
mixlib-cli
mixlib-config
mixlib-log
systemu
yajl-ruby
polyglot (0.3.3)
pry (0.9.8.4)
coderay (~> 1.0.5)
method_source (~> 0.7.1)
slop (>= 2.4.4, < 3)
rak (1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
slop (2.4.4)
systemu (2.5.2)
test-kitchen (0.6.0)
foodcritic (~> 1.4)
hashr (~> 0.0.20)
highline (>= 1.6.9)
librarian (~> 0.0.20)
mixlib-cli (~> 1.2.2)
vagrant (~> 1.0.2)
yajl-ruby (~> 1.1.0)
thor (0.16.0)
treetop (1.4.11)
polyglot
polyglot (>= 0.3.1)
uuidtools (2.1.3)
vagrant (1.0.5)
archive-tar-minitar (= 0.5.2)
childprocess (~> 0.3.1)
erubis (~> 2.7.0)
i18n (~> 0.6.0)
json (~> 1.5.1)
log4r (~> 1.1.9)
net-scp (~> 1.0.4)
net-ssh (~> 2.2.2)
yajl-ruby (1.1.0)

PLATFORMS
ruby

DEPENDENCIES
test-kitchen
19 changes: 18 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
default[:erlang][:gui_tools] = false
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

default['erlang']['gui_tools'] = false
39 changes: 39 additions & 0 deletions files/default/tests/minitest/default_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Cookbook:: erlang
# Minitest Chef Handler
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require File.expand_path('../support/helpers', __FILE__)

describe 'erlang::default' do
include Helpers::Erlang

it 'doesnt install the gui_tools if the attribute is false (default)' do
skip unless node['platform_family'] == 'debian'
skip if node['erlang']['gui_tools']
package("erlang-gs").wont_be_installed
end

it 'can process erlang code with the erl command ' do
erl = shell_out("erl -myflag 1 <<-EOH
init:get_argument(myflag).
EOH
")
erl.stdout.include?('{ok,[["1"]]}')
end
end
29 changes: 29 additions & 0 deletions files/default/tests/minitest/support/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Cookbook:: erlang
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module Helpers
module Erlang
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
include MiniTest::Chef::Assertions
include MiniTest::Chef::Context
include MiniTest::Chef::Resources

end
end
19 changes: 14 additions & 5 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@
# limitations under the License.
#

case node[:platform]
when "debian", "ubuntu"
erlpkg = node[:erlang][:gui_tools] ? "erlang" : "erlang-nox"
case node['platform_family']
when "debian"

erlpkg = node['erlang']['gui_tools'] ? "erlang-x11" : "erlang-nox"

package erlpkg
package "erlang-dev"
when "redhat", "centos", "scientific"

when "rhel"

include_recipe "yum::epel"

yum_repository "erlang" do
name "EPELErlangrepo"
url "http://repos.fedorapeople.org/repos/peter/erlang/epel-5Server/$basearch"
description "Updated erlang yum repository for RedHat / Centos 5.x - #{node['kernel']['machine']}"
action :add
only_if { node[:platform_version].to_f >= 5.0 && node[:platform_version].to_f < 6.0 }
only_if { node['platform_version'].to_f >= 5.0 && node['platform_version'].to_f < 6.0 }
end

package "erlang"

else

package "erlang"

end
22 changes: 22 additions & 0 deletions test/kitchen/Kitchenfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

cookbook "erlang" do
configuration "default"
configuration "gui_tools"
exclude :platform => "centos", :configuration => "gui_tools"
end
12 changes: 12 additions & 0 deletions test/kitchen/cookbooks/erlang_test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# CHANGELOG for erlang_test

This file is used to list changes made in each version of erlang_test.

## 0.1.0:

* Initial release of erlang_test

- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.

The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
12 changes: 12 additions & 0 deletions test/kitchen/cookbooks/erlang_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Description
===========

Requirements
============

Attributes
==========

Usage
=====

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Cookbook:: erlang
# Minitest Chef Handler
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require File.expand_path('../support/helpers', __FILE__)

describe 'erlang::default' do
include Helpers::Erlang

it 'installs the x11 package if gui_tools is true' do
skip unless node['platform_family'] == 'debian'
package("erlang-gs").must_be_installed
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Cookbook:: erlang
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2012, Opscode, Inc. <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module Helpers
module Erlang
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
include MiniTest::Chef::Assertions
include MiniTest::Chef::Context
include MiniTest::Chef::Resources

end
end
6 changes: 6 additions & 0 deletions test/kitchen/cookbooks/erlang_test/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs/Configures erlang_test"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1.0"
20 changes: 20 additions & 0 deletions test/kitchen/cookbooks/erlang_test/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Cookbook Name:: erlang_test
# Recipe:: default
#
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include_recipe "erlang::default"

0 comments on commit a882414

Please sign in to comment.